<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div>这是一个div</div>
    <script>
        //封装函数
        // 封装函数可以批量设置样式
        function setStyle() {
            var divDom = document.querySelector('div');[1].onclick = function () {
                divDom.style.width = '200px';
                divDom.style.height = '200px';
                divDom.style.color = 'gold';
                divDom.style.backgroundColor = 'pink';
            }
        }

    </script>
</body>

</html>